﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ValiVIN.Manufacturer
{
    internal class SmallManufacturer : IVINManufacturer
    {

        static Dictionary<string, IVINManufacturer> _manufacturers;

        private Dictionary<string, IVINManufacturer> Manufacturers
        {
            get
            {
                if (_manufacturers == null)
                {
                    GenerateManufacturers();
                }
                return _manufacturers;
            }
        }

        private void GenerateManufacturers()
        {
            _manufacturers = new Dictionary<string, IVINManufacturer>();
            _manufacturers["A12"] = (IVINManufacturer)LamborghiniOLD.Instance;
        }

        #region Singleton

        static readonly SmallManufacturer _instance = new SmallManufacturer();

        public static SmallManufacturer Instance
        {
            get { return _instance; }
        }

        #endregion


        #region IVINManufacturer Members

        public bool Decode(VINumber vin)
        {
            //Small Manufacturer WIM in 12-14
            string sWIM = vin.VIN.Substring(11, 3);

            if (Manufacturers.ContainsKey(sWIM))
            {
                return Manufacturers[sWIM].Decode(vin);
            }

            return false;
        }

        public string ManufacturerName(string vin)
        {
            //Small Manufacturer WIM in 12-14
            string sWIM = vin.Substring(11, 3);

            if (Manufacturers.ContainsKey(sWIM))
            {
                return Manufacturers[sWIM].ManufacturerName(vin);
            }

            return string.Empty;
        }

        #endregion
    }
}
